<template>
	<view class="container">
		<view class="bg-to-right" style="height: 210rpx">
			<kg-custom :isBack="false" bgColor="bg-to-right">
				<block slot="left">
					<view @click="chockAddress"
						class="text-15 padding-left-sm text-bold flex justify-start align-center">
						<image :src="baseUrl + '/static/position.png'" mode="" style="height: 28rpx; width: 28rpx">
						</image>
						<view class="margin-left-xs margin-right-xs text-221815">
							{{ address }}
						</view>
						<image :src="baseUrl + '/static/righted.png'" mode="" style="height: 14rpx; width: 14rpx">
						</image>
					</view>
				</block>
			</kg-custom>
		</view>
		<view class="bg-white padding-sm" style="
        border-top-left-radius: 46rpx;
        border-top-right-radius: 46rpx;
        margin-top: -46rpx;
      ">
			<view class="flex justify-start align-center bg-F4F4F4 padding-left round" style="height: 78rpx">
				<image :src="baseUrl + '/static/search_for.png'" mode="" style="width: 25rpx; height: 25rpx"></image>
				<input type="text" value="" confirm-type="search" @confirm="search" v-model="keywords"
					class="text-13 f-grow1 padding-left-sm" placeholder="搜索网点" />
			</view>
			<view class="text-15 flex justify-start align-center margin-top-sm">
				<scroll-view scroll-x class="bg-white nav text-666" style="width: calc(100% - 87rpx)"
					scroll-with-animation :scroll-left="scrollLeft">
					<!-- <view class="cu-item" :class="TabCur==999?'color cur text-bold':''" @tap="tabSelect" :data-id="999">
						首页
					</view> -->
					<view class="cu-item" :class="index == TabCur ? 'color cur text-bold' : ''"
						v-for="(item, index) in classification1" @click="tabSelect(index, item.id)">
						{{ item.name }}
					</view>
				</scroll-view>
				<view class="color" style="min-width: 87rpx" @click="
            toPage('/filePage/pages/classification/classification?type=2')
          ">
					全部
				</view>
			</view>
			<swiper class="margin-top-sm margin-bottom-sm" style="height: 266rpx" :indicator-dots="true"
				:autoplay="true" :interval="3000" circular="true" :duration="1000" indicator-color="#F4F4F4"
				indicator-active-color="#ED7200">
				<swiper-item v-for="item in banners" @click="toLink(item)">
					<image class="width-sub height-sub radius10" :src="item.pic" mode=""></image>
				</swiper-item>
			</swiper>
			<view class="position-relative">
				<swiper class="classification-swiper" circular="true" @change="change" :duration="1000"
					indicator-color="#F4F4F4" indicator-active-color="#ED7200">
					<swiper-item v-for="item in classification2">
						<view class="cu-list flex justify-start flex-wrap">
							<view @click="
                  toPage(
                    '/filePage/pages/verified/verified?sysCategoryId=' +
                      im.id +
                      '&sysCategoryName=' +
                      im.name,2
                  )
                " v-for="im in item" style="width: 20%; padding: 19rpx"
								class="cu-item text-sm flex flex-direction justify-center align-center">
								<image :src="im.icon" mode="" style="width: 48rpx; height: 48rpx"></image>
								<view class="margin-top-sm">
									{{ im.name }}
								</view>
							</view>
						</view>
					</swiper-item>
				</swiper>
				<view class="flex dots">
					<view class="dot" :class="[current == i ? 'curr-dot' : '']" v-for="(d, i) in classification2"
						:key="i">
					</view>
				</view>
			</view>
		</view>
		<view class="bg-white flex justify-between align-center padding margin-sm text-sm radius10">
			<view class="flex justify-start align-center">
				<image :src="baseUrl + '/static/Notice.png'" mode=""
					style="width: 26rpx; min-width: 26rpx; height: 26rpx"></image>
				<view class="color text-bold margin-left-xs padding-right-xs" style="border-right: 2rpx solid #dadada">
					{{ orderCount }}人已接单
				</view>
			</view>
			<swiper class="f-grow1" style="height: 32rpx" :autoplay="true" :interval="3000" circular="true"
				:duration="1000" indicator-color="#F4F4F4" indicator-active-color="#ED7200" :vertical="true">
				<swiper-item v-for="item in orderNewest">
					<view class="flex justify-between align-center f-grow1">
						<view class="text-F94000 margin-left-xs">
							{{ item.orderServiceCategory }}
						</view>
						<view class="margin-left-sm text-999 text-cut" style="max-width: 260rpx">
							{{ item.receiverName }}已成功接单
						</view>
						<view class="">
							{{ item.receivePastTime }}
						</view>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<image v-if="turntable" @click="toPage('/pagesA/pages/turntable/turntable')"
			:src="baseUrl + '/static/turntable.png'" mode="" class="width-sub" style="height: 200rpx"></image>
		<view class="flex justify-start align-center margin-sm" v-if="is_flag">
			<view class="f-grow1 flex justify-start align-center padding-sm bg-white radius10"
				@click="toPage('/filePage/pages/verified/verified')">
				<image :src="baseUrl + '/static/Send_order.png'" mode=""
					style="width: 58rpx; height: 58rpx; min-width: 58rpx"></image>
				<view class="margin-left-sm">
					<view class="text-15 text-bold text-221815"> 我要发单 </view>
					<view class="margin-top-sm text-767696 text-11">
						发布安装维修信息
					</view>
				</view>
			</view>
			<view class="margin-left-sm f-grow1 flex justify-start align-center padding-sm bg-white radius10"
				@click="toPage('/filePage/pages/Ship/Ship')">
				<image :src="baseUrl + '/static/Ship.png'" mode=""
					style="width: 58rpx; height: 58rpx; min-width: 58rpx">
				</image>
				<view class="margin-left-sm">
					<view class="text-15 text-bold text-221815"> 我要发货 </view>
					<view class="margin-top-sm text-767696 text-11">
						一键发货、为您跑腿
					</view>
				</view>
			</view>
		</view>
		<view v-if="ProductList.length > 0" class="flex justify-between align-center margin-sm padding-top-sm radius10">
			<view class="text-17 text-bold text-221815"> 推荐商品 </view>
			<view @click="toPage('/filePage/pages/goods-list/goods-list')"
				class="text-sm text-999 flex justify-start align-center">
				<view class="margin-right-xs"> 查看更多 </view>
				<image :src="baseUrl + '/static/right.png'" mode="" style="width: 14rpx; height: 14rpx"></image>
			</view>
		</view>
		<view class="list flex flex-wrap justify-start">
			<view class="item margin-top-sm radius10 position-relative" v-for="(item, index) in ProductList"
				:key="index" :class="{ '.margin-left14': index % 2 != 0 }" @click.stop="
          toPage('/filePage/pages/goods-detail/goods-detail?id=' + item.id)
        ">
				<view v-if="item.newStatus == 1" class="text-sm text-white flex justify-center align-center"
					:style="'background-image: url(' + baseUrl + '/static/shop_bg2.png);'" style="
            width: 70rpx;
            height: 36rpx;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 1;
            background-size: 100% 100%;
          ">
					新品
				</view>
				<image :src="item.pic" mode="" class="radius-t-l radius-t-r"></image>
				<view class="padding-sm">
					<view class="text-cut text-15">
						{{ item.name }}
					</view>
					<view class="color text-sm margin-top-sm">
						¥{{ parseFloat(item.price / 100).toFixed(2) }}
					</view>
					<view class="flex justify-between align-center margin-top-sm">
						<view class="text-sm text-999 text-delete">
							¥{{ parseFloat(item.originalPrice / 100).toFixed(2) }}
						</view>
						<image @click.stop="showSku(item.id)" :src="baseUrl + '/static/cart.png'" mode=""
							style="width: 28rpx; height: 28rpx"></image>
					</view>
				</view>
			</view>
		</view>

		<view class="flex justify-between align-center margin-sm padding-top-sm radius10">
			<view class="text-17 text-bold text-221815"> 附近服务网点 </view>
			<view class="text-sm text-999 flex justify-start align-center">
				<view class="margin-right-xs"> 5000+优秀服务网点为您服务 </view>
				<!-- <image :src="baseUrl + '/static/right.png'" mode="" style="width: 14rpx;height: 14rpx;"></image> -->
			</view>
		</view>
		<view class="padding-sm margin-sm bg-white flex justify-start align-center radius10" v-for="item in list"
			@click="
        toPage('/filePage/pages/nearby-ship/nearby-ship?shopId=' + item.id)
      ">
			<image :src="item.logo" mode="" style="width: 220rpx; min-width: 220rpx; height: 220rpx"></image>
			<view class="f-grow1 margin-left-xs">
				<view class="text-15 text-black text-bold">
					{{ item.shopName }}
				</view>
				<view class="text-cut-2 text-666 margin-top">
					擅长：
					<text v-for="(sc, index) in item.shopServiceSupportList">
						{{ sc.shopServiceName }}
						<text v-if="index < item.shopServiceSupportList.length - 1">、</text>
					</text>
				</view>
				<view class="flex justify-between align-center text-sm" style="margin-top: 56rpx">
					<view class="color"> 评价 {{ item.commentCount }} </view>
					<view class="text-767696"> 距离 {{ item.distance }}m </view>
				</view>
			</view>
		</view>
		<uni-load-more :status="loading" />
		<view class="cu-modal" :class="modalName == 'ModalAuthor' ? 'show' : ''">
			<view class="cu-dialog bg-white">
				<view class="cu-bar justify-end">
					<view class="content">提示</view>
				</view>
				<view class="padding-xl text-20"> 请先授权登录 </view>
				<view class="flex justify-between align-center padding text-lg">
					<view @click="hideModal" class="bg-D7D7D7 text-gray radius5" style="padding: 32rpx 96rpx">
						取消
					</view>
					<button v-if="canIUseProfile == false" open-type="getUserInfo" @getuserinfo="getUserInfo"
						class="bg-color text-white radius5" style="padding: 32rpx 96rpx">
						确定
					</button>
					<button v-else @tap="getUserInfo" class="bg-color text-white radius5" style="padding: 32rpx 96rpx">
						确定
					</button>
				</view>
			</view>
		</view>
		<!-- 定位授权 -->
		<view class="cu-modal" :class="modalName == 'ModalAddress' ? 'show' : ''">
			<view class="cu-dialog bg-white">
				<view class="cu-bar justify-end">
					<view class="content">提示</view>
				</view>
				<view class="padding-xl text-20"> 请先授权地理定位 </view>
				<view class="flex justify-between align-center padding text-lg">
					<view @click="hideModal" class="bg-D7D7D7 text-gray radius5" style="padding: 32rpx 96rpx">
						取消
					</view>
					<button @click="getLocal" class="bg-color text-white radius5" style="padding: 32rpx 96rpx">
						确定
					</button>
				</view>
			</view>
		</view>
		<view class="cu-modal" :class="{ show: isShow }">
			<view class="cu-dialog bg-white">
				<view class="cu-bar justify-end">
					<view class="content">提示</view>
				</view>
				<view class="padding-xl text-20"> 获取用户手机号 </view>
				<view class="flex justify-between align-center padding text-lg">
					<view @click="isShow = false" class="bg-D7D7D7 text-gray radius5" style="padding: 32rpx 96rpx">
						取消
					</view>
					<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
						class="bg-color text-white radius5" style="padding: 32rpx 96rpx">
						确定
					</button>
				</view>
			</view>
		</view>

		<!--底部 sku 选择弹窗 -->
		<wui-specification :goodsInfo="goodsInfo" btnType="1" :show="show" @select="selectSku" @close="hideSku">
		</wui-specification>
	</view>
</template>

<script>
	import BetterPull from "@/common/libs/BetterPull";
	export default {
		mixins: [
			BetterPull({
				async getPage(page, done) {
					this.loading = "loading";
					let param;
					if (this.keywords) {
						param = {
							pageNum: page,
							pageSize: 10,
							keywords: this.keywords,
						};
					} else {
						param = {
							pageNum: page,
							pageSize: 10,
						};
					}
					const [err, res] = await this.$get(
						this.$api.home_listNearbyShop,
						param
					);
					if (res) {
						// console.log(res)
						var data = res.data.list;
						this.total = res.data.total;
						done(data);
						if (data.length < 10) {
							this.loading = "noMore";
						} else {
							this.loading = "more";
						}
						// console.log(this.loading)
					}
					if (err) {
						done([]);
						this.loading = "noMore";
					}
				},
			}),
		],
		data() {
			return {
				current: 0,
				TabCur: "",
				classification1Id: "",
				scrollLeft: 0,
				baseUrl: this.$config.baseUrl,
				banners: [],
				address: "",
				classification1: [],
				pageNum: 1,
				classification2: [],
				orderCount: 0,
				orderNewest: [],
				loading: "more",
				ProductList: [],
				latitude: "",
				longitude: "",
				modalName: null,
				total: 0,
				keywords: "",
				show: false,
				goodsInfo: {},
				selectInfo: {
					difference: "请选择规格",
				}, //存放最后选中的商品
				canIUseProfile: false,
				userInfo: {},
				isShow: false,
				session_key: "",
				phoneNumber: "",
				is_flag: "",
				turntable: "",
				recommendCode:''
			};
		},
		onLoad() {
			// #ifdef MP-WEIXIN
			if (wx.getUserProfile) {
				// console.log("--check getUserProfile--OK");
				this.canIUseProfile = true;
			}
			// #endif
			let that = this;
			uni.getLocation({
				type: "gcj02",
				success: function(res) {
					that.latitude = res.latitude;
					that.longitude = res.longitude;
					// console.log("当前位置的经度：" + res.longitude);
					// console.log("当前位置的纬度：" + res.latitude);
					that.getAddress(res.longitude, res.latitude);
				},
				fail(err) {
					// console.log(err);
					// #ifdef MP-WEIXIN
					this.modalName = "ModalAddress";
					// #endif

					// #ifdef APP-PLUS
					uni.showModal({
						title: "提示",
						content: "获取定位失败，是否授权打开定位",
						success: (res) => {
							if (res.confirm) {
								uni.getSystemInfo({
									success: (sys) => {
										if (sys.platform == "ios") {
											plus.runtime.openURL("app-settings://");
										} else {
											var main = plus.android.runtimeMainActivity();
											var Intent = plus.android.importClass(
												"android.content.Intent"
											);
											//可能应该直接进入应用列表的权限设置？=> android.settings.APPLICATION_SETTINGS
											var mIntent = new Intent(
												"android.settings.LOCATION_SOURCE_SETTINGS"
											);
											main.startActivity(mIntent);
										}
									},
								});
							}
						},
					});
					// #endif
				},
			});
			this.getBanner();
			this.getClassification();
			this.getOrderCount();
			this.getOrderNewest();
			this.getProductList();
		},
		onShow() {
			uni.$emit("isBack", false);
			this.getFlag();
			this.getTurntable();
			if(uni.getStorageSync('scene')){
				this.recommendCode  = uni.getStorageSync('scene')
			}
			
		},
		onPageScroll(res) {
			// console.log(res.scrollTop);//距离页面顶部距离
		},
		onPullDownRefresh() {
			console.log(1111)
			this.getBanner();
			this.getClassification();
			this.getOrderCount();
			this.getOrderNewest();
			this.getProductList();

		},
		methods: {
			async getTurntable() {
				const [err, res] = await this.$get(this.$api.lotteryStatus, {
					type: 1,
				});
				if (res) {
					this.turntable = res.data;
					// console.log(res)
				}
			},
			async getFlag() {
				const [err, res] = await this.$get(this.$api.hiddenFlag);
				if (res) {
					this.is_flag = res.data;
					// #ifdef MP-WEIXIN
					if (res.data) {
						uni.showTabBar();
					}
					// #endif

					uni.setStorage({
						key: "is_flag",
						data: res.data,
					})
				}
			},
			showSku(e) {
				let that = this;
				this.goodsInfo = {};

				if (this.latitude) {
					uni.getStorage({
						key: "userId",
						success: function() {
							that.getInfo(e);
						},
						fail: function() {
							// #ifdef MP-WEIXIN
							that.modalName = "ModalAuthor";
							// #endif
							// #ifdef APP-PLUS
							uni.navigateTo({
								url: "/pages/login/login",
							});
							// #endif

						},
					});
				} else {
					this.modalName = "ModalAddress";
				}
			},
			hideSku(e) {
				this.show = false;
				this.selectInfo = e;
				// console.log(e)
			},
			selectSku(options) {
				//点击sku弹窗中的加入购物车或结算按钮
				this.show = false;
				this.selectInfo = options;
				this.addCart();
			},
			async getInfo(e) {
				const [err, res] = await this.$get(this.$api.product_detail, {
					id: e,
				});
				if (res) {
					this.show = true;
					this.goodsInfo = res.data;
				}
			},
			async addCart() {

				console.log(111)

				// console.log(this.selectInfo)
				const [err, res] = await this.$post(this.$api.car_add, {
					attributes: this.selectInfo.difference,
					buyNum: this.selectInfo.num,
					price: this.selectInfo.price,
					productId: this.goodsInfo.id,
					productImg: this.selectInfo.pic ?
						this.selectInfo.pic : this.goodsInfo.pic,
					productName: this.goodsInfo.name,
					shopId: this.goodsInfo.shopId,
					shopImg: this.goodsInfo.shopImg,
					shopName: this.goodsInfo.shopName,
					skuId: this.selectInfo.id,
				});

				console.log(err, res)

				if (res) {
					// console.log(res)
					this.$util.msg("加入购物车成功");
					// setTimeout(() => {
					// 	uni.navigateBack()
					// }, 1500)
				}
			},
			search() {
				this.list = [];
				uni.startPullDownRefresh();
				this.getProductList();
			},
			async getUserInfo() {
				let that = this;
				// this.hideModal()
				// this.modalName = null
				if (that.canIUseProfile == false) {
					uni.login({
						provider: "weixin",
						success: function(loginRes) {
							// console.log(loginRes);
							uni.getUserInfo({
								provider: "weixin",
								success: function(infoRes) {
									// console.log(infoRes);
									that.getLogin(
										loginRes.code,
										res.userInfo.nickName,
										res.userInfo.avatarUrl
									);
								},
							});
						},
					});
				} else {
					// console.log(1111);
					uni.getUserProfile({
						desc: "Wexin",
						success: function(res) {
							// console.log("wx.getUserProfile=>用户允许了授权");
							// console.log(res.userInfo);
							// // console.log( res.rawData );
							// console.log(res.signature);
							// console.log(res.encryptedData);
							// console.log(res.iv);
							uni.login({
								provider: "weixin",
								success: function(loginRes) {
									console.log(loginRes);
									that.getLogin(
										loginRes.code,
										res.userInfo.nickName,
										res.userInfo.avatarUrl
									);
								},
							});
						},
						fail(rs) {
							console.log(rs);
						},
					});
				}
			},
			getLocal() {
				let that = this;
				this.modalName = null;

				uni.openSetting({
					success: (re) => {
						if (re.authSetting) {
							uni.getLocation({
								type: "gcj02",
								success: function(res) {
									that.latitude = res.latitude;
									that.longitude = res.longitude;
									// console.log("当前位置的经度：" + res.longitude);
									// console.log("当前位置的纬度：" + res.latitude);
									that.getAddress(res.longitude, res.latitude);
								},
								fail(err) {
									console.log(err);
								},
							});
						}
					},
					fail: (er) => {
						console.log("``````" + JSON.stringify(er));
					},
				});
			},
			async getLogin(code, nickName, avatarUrl) {
				let that = this;
				if (!this.latitude && !this.longitude) {
					this.modalName = "ModalAddress";
				} else {
					uni.showLoading({
						title: "正在登录",
						mask: true,
					});
					const data = {
						code: code,
						nickname: nickName,
						headimg: avatarUrl,
						latitude: this.latitude,
						longitude: this.longitude,
					};
					if (this.recommendCode) {
						data["recommendCode"] = this.recommendCode;
					}
					const [err, res] = await this.$post(this.$api.loginWX,data);
					if (res) {
						// console.log(res)
						this.isShow = true;
						this.session_key = res.data.session_key;
						uni.setStorage({
							key: "session_key",
							data: res.data.session_key,
						});
						uni.setStorage({
							key: "token",
							data: res.data.openid,
						});
						uni.setStorage({
							key: "userId",
							data: res.data.userId,
						});
						uni.setStorage({
							key: "openid",
							data: res.data.openid,
						});
						this.modalName = null;
						uni.hideLoading();
						this.getUser();
						this.$util.msg(res.message);
					}
				}
			},
			hideModal() {
				this.modalName = null;
			},
			tabSelect(e, id) {
				this.TabCur = e;
				this.classification1Id = id;
				this.scrollLeft = (e - 1) * 60;
				this.getClassification2();
			},
			scroll: function(e) {
				// console.log(e)
				this.old.scrollTop = e.detail.scrollTop;
			},
			change(event) {
				let current = event.detail.current;
				this.current = current;
			},
			toPage(url, i) {
				// console.log(111)
				let that = this;
				if (this.latitude) {
					uni.getStorage({
						key: "userId",
						success: function() {
							if (
								url == "/filePage/pages/big-screen/big-screen" ||
								url == "/filePage/pages/verified/verified" ||
								url == "/filePage/pages/Ship/Ship" ||
								i
							) {
								// console.log('``````',that.userInfo)
								that.getUser(url)
							} else {
								that.$util.openNewPage(url);
							}
						},
						fail: function() {
							// #ifdef MP-WEIXIN
							that.modalName = "ModalAuthor";
							// #endif
							// #ifdef APP-PLUS
							uni.navigateTo({
								url: "/pages/login/login",
							});
							// #endif
						},
					});
				} else {
					// #ifdef APP-PLUS
					uni.getLocation({
						type: "gcj02",
						success: function(res) {
							that.latitude = res.latitude;
							that.longitude = res.longitude;
							// console.log("当前位置的经度：" + res.longitude);
							// console.log("当前位置的纬度：" + res.latitude);
							that.getAddress(res.longitude, res.latitude);
						},
						fail(err) {
							console.log(err);
							uni.showModal({
								title: "提示",
								content: "获取定位失败，是否授权打开定位",
								success: (res) => {
									if (res.confirm) {
										uni.getSystemInfo({
											success: (sys) => {
												if (sys.platform == "ios") {
													plus.runtime.openURL(
														"app-settings://");
												} else {
													var main = plus.android
														.runtimeMainActivity();
													var Intent = plus.android.importClass(
														"android.content.Intent"
													);
													//可能应该直接进入应用列表的权限设置？=> android.settings.APPLICATION_SETTINGS
													var mIntent = new Intent(
														"android.settings.LOCATION_SOURCE_SETTINGS"
													);
													main.startActivity(mIntent);
												}
											},
										});
									}
								},
							});
						},
					});
					// #endif

					// #ifdef MP-WEIXIN
					this.modalName = "ModalAddress";
					// #endif
				}
			},
			async getBanner() {
				const [err, res] = await this.$get(this.$api.home_getAdvertisementList, {
					adPositionType: 1,
				});
				if (res) {
					this.banners = res.data;
					// console.log(res)
				}
			},
			chockAddress() {
				let that = this;
				// #ifdef  APP-PLUS
				uni.navigateTo({
					url: "/pagesA/pages/chooseLocation/chooseLocation",
					animationType: "slide-in-bottom",
				})
				// #endif

				// #ifdef  MP-WEIXIN
				uni.chooseLocation({

					success: function(res) {
						// console.log('位置名称：' + res.name);
						// console.log('详细地址：' + res.address);
						// console.log('纬度：' + res.latitude);
						// console.log('经度：' + res.longitude);
						that.latitude = res.latitude;
						that.longitude = res.longitude;
						// console.log('当前位置的经度：' + res.longitude);
						// console.log('当前位置的纬度：' + res.latitude);
						that.getAddress(res.longitude, res.latitude);
					},
				});
				// #endif


			},
			async getAddress(longitude, latitude) {
				console.log(longitude, latitude)
				const [err, res] = await this.$get(this.$api.home_position, {
					longitude: longitude,
					latitude: latitude,
					coordinateType: "gcj02ll",
				});
				if (res) {
					this.address = res.data.address;
					this.list = [];
					uni.startPullDownRefresh();
					// console.log(res)
				}
			},
			async getClassification() {
				const [err, res] = await this.$get(this.$api.home_categoryTreeList, {
					type: 2,
				});
				if (res) {
					this.classification1 = res.data;
					if (this.classification1.length > 0) {
						this.classification1Id = this.classification1[0].id;
						this.getClassification2();
					}
				}
			},
			async getClassification2() {
				const [err, res] = await this.$get(this.$api.home_productCateList, {
					parentId: this.classification1Id,
					type: 2,
				});
				if (res) {
					this.classification2 = this.$util.spArr(res.data, 10);
					// console.log(res)
				}
			},
			async getOrderCount() {
				const [err, res] = await this.$get(this.$api.home_orderServiceCount);
				if (res) {
					this.orderCount = res.data;
					// console.log(res)
				}
			},
			async getOrderNewest() {
				const [err, res] = await this.$get(this.$api.home_orderServiceNewest);
				if (res) {
					this.orderNewest = res.data;
					// console.log(res)
				}
			},
			async getProductList() {
				const [err, res] = await this.$get(this.$api.home_recommendProductList, {
					pageNum: 1,
					pageSize: 10,
					keywords: this.keywords,
				});
				if (res) {
					if (this.keywords) {
						uni.pageScrollTo({
							duration: 500, // 毫秒
							scrollTop: 580, // 位置
						});
					}

					this.ProductList = res.data.list;

					// console.log(res)
				}
			},
			async getUser(e) {
				const [err, rs] = await this.$get(this.$api.userDetail);
				const that = this
				if (rs) {
					// console.log(rs)
					this.userInfo = rs.data
					if (e) {
						if (rs.data.userIdentityStatus == 1) {
							this.$util.openNewPage(e);
					
						} else {
							uni.showModal({
								title: "提示",
								content: "您还没有认证",
								cancelText: "再看看",
								confirmText: "去认证",
								success: (res) => {
									if (res.confirm) {
										that.$util.openNewPage(
											"/filePage/pages/real-name/real-name"
										);
									}
								},
							});
						}
					}
					
					uni.setStorageSync("userInfo", rs.data);
				}
			},
			toLink(e) {
				let that = this;

				uni.getStorage({
					key: "userId",
					success: function() {
						if (e.redirectType == 1) {
							// #ifdef APP-PLUS
							plus.runtime.openURL(encodeURI(e.redirectUrl), function(res) {
								console.log(res);
							});
							// #endif
							// #ifdef MP-WEIXIN
							that.$util.openNewPage(
								"/filePage/pages/open-link/open-link?url=" + e.redirectUrl
							);
							// #endif
						} else {
							that.$util.openNewPage(
								"/filePage/pages/goods-detail/goods-detail?id=" + e.redirectUrl
							);
						}
					},
					fail() {

						// #ifdef MP-WEIXIN
						that.modalName = "ModalAuthor";
						// #endif
						// #ifdef APP-PLUS
						uni.navigateTo({
							url: "/pages/login/login",
						});
						// #endif
					}

				})
			},
			async getPhoneNumber(e) {
				this.isShow = false;
				console.log(e);
				var iv = e.detail.iv;
				var encryptedData = e.detail.encryptedData;
				var session_key;
				if (uni.getStorageSync("session_key")) {
					session_key = uni.getStorageSync("session_key");
				} else {
					session_key = this.session_key;
				}
				const data = {
					session_key,
					iv,
					encryptedData,
				};
				const [err, rs] = await this.$get(this.$api.getWXPhone, data);
				if (rs) {
					this.$util.msg(rs.message);
					uni.setStorageSync("mobile", rs.data.mobile);
				}
			},
		},
	};
</script>

<style lang="scss" scoped>
	.classification-swiper {
		height: 318rpx;
	}

	.dots {
		display: flex;
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		bottom: 20rpx;

		.dot {
			width: 30rpx;
			height: 4rpx;
			border-radius: 6rpx;
			background-color: #d6d6d6;
			margin-right: 8rpx;
		}

		.curr-dot {
			width: 30rpx;
			height: 4rpx;
			border-radius: 6rpx;
			background-color: #ed7200;
		}
	}

	.list {
		padding: 0 20rpx;

		.item {
			image {
				width: 100%;
				height: 348rpx;
			}

			background: #fff;
			width: 348rpx;
		}
	}
</style>
